<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="区县" prop="qy">
        <el-select v-model="queryParams.qy" placeholder="请选择" clearable size="small">
          <el-option
            v-for="dict in qyList"
            :key="dict.n"
            :label="dict.n"
            :value="dict.v"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="学校" prop="zxmc">
        <el-select v-model="queryParams.zxmc" placeholder="请选择" clearable filterable size="small">
          <el-option
            v-for="dict in zxmcList"
            :key="dict.zxmc"
            :label="dict.zxmc"
            :value="dict.zxmc">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="班级" prop="bjdm">
        <el-select v-model="queryParams.bjdm" placeholder="请选择" clearable size="small">
          <el-option
            v-for="dict in bjdmList"
            :key="dict.bjdm"
            :label="dict.bjdm"
            :value="dict.bjdm"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="准考号" prop="zkh">
        <el-input
          v-model="queryParams.zkh"
          placeholder="请输入"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="建档号" prop="jdh">
        <el-input
          v-model="queryParams.jdh"
          placeholder="请输入"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="打印状态" prop="dyzh">
        <el-select v-model="queryParams.dyzh" placeholder="请选择" clearable size="small">
          <el-option
            v-for="dict in dict.type.point_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="考试状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择" clearable size="small">
          <el-option
            v-for="dict in dict.type.candidate_process_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="考试时间" prop="startTime">
        <el-date-picker clearable size="small"
                        v-model="queryParams.startTime"
                        type="datetime"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        placeholder="选择开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="" prop="endTime">
        <el-date-picker clearable size="small"
                        v-model="queryParams.endTime"
                        type="datetime"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        placeholder="选择结束时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handlePrint"
          v-hasPermi="['business:examSummaryResults:print']"
        >打印
        </el-button>
      </el-col>
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="warning"-->
<!--          plain-->
<!--          icon="el-icon-download"-->
<!--          size="mini"-->
<!--          :loading="exportLoading"-->
<!--          @click="handleExport"-->
<!--          v-hasPermi="['business:examSummaryResults:export']"-->
<!--        >导出-->
<!--        </el-button>-->
<!--      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['business:examSummaryResults:export2']"
        >不含成绩导出
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExportOld"
          v-hasPermi="['business:examSummaryResults:export2']"
        >含成绩导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="resultList">
      <el-table-column label="序号" type="index" align="center">
        <template slot-scope="scope">
          <span>{{ scope.$index + (queryParams.pageNo - 1) * queryParams.pageSize + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="学校名称" align="center" prop="school" width="120"/>
      <el-table-column label="学校代码" align="center" prop="schoolCode"/>
      <el-table-column label="班级代码" align="center" prop="schoolClass"/>
      <el-table-column label="考生姓名" align="center" prop="ksName"/>
      <el-table-column label="准考号" align="center" prop="zkz" width="120"/>
      <el-table-column label="性别" align="center" prop="gender" width="50">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.gender"/>
        </template>
      </el-table-column>
      <el-table-column label="必测项" align="center" prop="bctyxmName" width="220">
        <template slot-scope="scope">
          <span>{{ returnExamInfo(scope.row.bctyxmName, scope.row.bctyxmStatus, scope.row.bctyxmValue) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="选测项1" align="center" prop="xctyxm1Name" width="180">
        <template slot-scope="scope">
          <span>{{ returnExamInfo(scope.row.xctyxm1Name, scope.row.xctyxm1Status, scope.row.xctyxm1Value) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="选测项2" align="center" prop="xctyxm2Name" width="180">
        <template slot-scope="scope">
          <span>{{ returnExamInfo(scope.row.xctyxm2Name, scope.row.xctyxm2Status, scope.row.xctyxm2Value) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="平时成绩" align="center" prop="usualResults"/>
      <el-table-column label="打印状态" align="center" prop="dyzt"/>
      <el-table-column label="状态" align="center" prop="qkzt"/>
      <el-table-column label="考试时间" align="center" prop="gmtModified"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width print-display">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdateType11(scope.row)"
            v-hasPermi="['business:examSpecialRecords:create3']"
          >三项重考
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdateType22(scope.row)"
            v-hasPermi="['business:examSpecialRecords:create']"
          >重考登记
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdateType33(scope.row)"
            v-hasPermi="['business:examResults:updateResult']"
          >成绩修正
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 异议处理-三项重考 -->
    <el-dialog :title="updateTitle1" :visible.sync="updateOpen1" width="500px" append-to-body>
      <el-form ref="form1" :model="form1" :rules="rules" label-width="80px">
        <el-form-item label="考生照片">
          <el-image style="width: 160px; height: 200px" :src="dialogImageUrl"
                    v-if="dialogImageUrl!=null"></el-image>
        </el-form-item>
        <el-form-item label="姓名" prop="ksName">
          <el-input v-model="form1.ksName" :disabled="true"/>
        </el-form-item>
        <el-form-item label="准考号" prop="zkz">
          <el-input v-model="form1.zkz" :disabled="true"/>
        </el-form-item>
        <el-form-item label="处理方式" prop="type">
          <el-select v-model="form1.type" placeholder="全部" clearable size="small" :disabled="true">
            <el-option
              v-for="dict in dict.type.specialTypes"
              :key="dict.value"
              :label="dict.raw.remark"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="原因" prop="reason">
          <el-input v-model="form1.reason" type="textarea" placeholder="请输入"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm1">确 定</el-button>
        <el-button @click="cancel1">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 异议处理-重考登记 -->
    <el-dialog :title="updateTitle2" :visible.sync="updateOpen2" width="500px" append-to-body>
      <el-form ref="form2" :model="form2" :rules="rules" label-width="80px">
        <el-form-item label="考生照片">
          <el-image style="width: 160px; height: 200px" :src="dialogImageUrl"
                    v-if="dialogImageUrl!=null"></el-image>
        </el-form-item>
        <el-form-item label="姓名" prop="ksName">
          <el-input v-model="form2.ksName" :disabled="true"/>
        </el-form-item>
        <el-form-item label="准考号" prop="zkz">
          <el-input v-model="form2.zkz" :disabled="true"/>
        </el-form-item>
        <el-form-item label="处理项目" prop="xmlx">
          <el-select v-model="form2.xmlx" clearable size="small">
            <el-option
              v-for="list in xmlxList"
              :key="list.value"
              :label="list.label"
              :value="list.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="处理方式" prop="type">
          <el-select v-model="form2.type" placeholder="全部" clearable size="small" :disabled="true">
            <el-option
              v-for="dict in dict.type.specialTypes"
              :key="dict.value"
              :label="dict.raw.remark"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="原因" prop="reason">
          <el-input v-model="form2.reason" type="textarea" placeholder="请输入"/>
        </el-form-item>
        <div style="color: red"> *备注：确定本项目重考，将取消该项目全部成绩。</div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm2">确 定</el-button>
        <el-button @click="cancel2">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 异议处理-成绩修正 -->
    <el-dialog :title="updateTitle3" :visible.sync="updateOpen3" width="500px" append-to-body>
      <el-form ref="form3" :model="form3" :rules="rules" label-width="80px">
        <el-form-item label="考生照片">
          <el-image style="width: 160px; height: 200px" :src="dialogImageUrl"
                    v-if="dialogImageUrl!=null"></el-image>
        </el-form-item>
        <el-form-item label="姓名" prop="ksName">
          <el-input v-model="form3.ksName" :disabled="true"/>
        </el-form-item>
        <el-form-item label="准考号" prop="zkz">
          <el-input v-model="form3.zkz" :disabled="true"/>
        </el-form-item>
        <el-form-item label="处理项目" prop="xmlx">
          <el-select v-model="form3.xmlx" clearable size="small" @change="changeOption3">
            <el-option
              v-for="list in xmlxList"
              :key="list.value"
              :label="list.label"
              :value="list.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="原成绩" prop="cj">
          <el-input v-model="form3.cj" :disabled="true"/>
        </el-form-item>
        <el-form-item label="处理方式" prop="type">
          <el-select v-model="form3.type" placeholder="全部" clearable size="small" :disabled="true">
            <el-option
              v-for="dict in dict.type.specialTypes"
              :key="dict.value"
              :label="dict.raw.remark"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="修正成绩" prop="result">
          <el-input-number v-model="form3.result" @change="computeFraction()" :min="0" :precision="2"/>
        </el-form-item>
        <el-form-item label="修正分数" prop="score">
          <el-input-number v-model="form3.score" :disabled="true"/>
        </el-form-item>
        <el-form-item label="原因" prop="reason">
          <el-input v-model="form3.reason" type="textarea" placeholder="请输入"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm3">确 定</el-button>
        <el-button @click="cancel3">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="passwordTitle" v-if="passwordOpen" :visible.sync="passwordOpen" width="500px">
      <el-form ref="passwordForm" :model="passwordForm" label-width="100px">
        <el-form-item label="密码" prop="password" :rules="{ required: true, message: '请输入密码', trigger: 'blur' }">
          <el-input type="password" v-model="passwordForm.password"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitPasswordForm">确 定</el-button>
        <el-button @click="passwordCancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  computeFraction,
  exportResult,
  exportResult2,
  listResult,
  print
} from '@/api/business/examSummaryResult/examSummaryResult'
import { candidatesDetail, examProjectsList, schoolClass } from '@/api/business/candidate/candidate'
import { printExcel1 } from '@/api/system/pointExcel1'
import { examSpecialRecords, examSpecialRecords3, updateResult } from '@/api/business/candidateResult/candidateResult'
import { getSuZhouQuYu } from '@/api/area'
import { getResult } from '@/api/business/arbitration/arbitration'
import { listSchool } from '@/api/business/school/school'

export default {
  name: 'Result',
  dicts: ['sys_user_sex', 'specialTypes', 'candidate_process_status', 'point_status', 'extra_password'],
  data() {
    return {
      passwordTitle: '',
      passwordOpen: false,
      passwordForm: {
        password: ''
      },
      passwordLabel: '',
      passwordRow: null,
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 考生考试项目汇总成绩表格数据
      resultList: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        qy: null,
        zxmc: null,
        bjdm: null,
        name: null,
        zkh: null,
        jdh: null,
        dyzh: null,
        status: null,
        startTime: null,
        endTime: null
      },
      zxmcList: [],
      bjdmList: [],
      projectIdList: [],
      xmlxList: [],
      form1: {},
      form2: {},
      form3: {},
      updateTitle1: null,
      updateTitle2: null,
      updateTitle3: null,
      updateOpen1: null,
      updateOpen2: null,
      updateOpen3: null,
      rules: {
        result: [],
        xmlx: [
          { required: true, message: '项目类型不能为空', trigger: 'blur' }
        ],
        reason: [
          { required: true, message: '原因不能为空', trigger: 'blur' }
        ]
      },
      displayResult: 'display: none',
      qyList: [],
      displayXmlx: '',
      dialogImageUrl: null
    }
  },
  created() {
    this.getList()
    listSchool().then(response => {
      this.zxmcList = response.rows
    })
    schoolClass().then(response => {
      this.bjdmList = response.data
    })
    examProjectsList().then(response => {
      this.projectIdList = response.data
    })
    getSuZhouQuYu().then(response => {
      this.qyList = response.data
    })
  },
  methods: {
    /** 查询考生考试项目汇总成绩列表 */
    getList() {
      this.loading = true
      listResult(this.queryParams).then(response => {
        this.resultList = response.data.records
        this.total = response.data.totalCount
        this.loading = false
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },
    /** 导出按钮操作 */
    handleExportOld() {
      const queryParams = this.queryParams
      this.$modal.confirm('是否确认导出所有查询数据项？').then(() => {
        this.exportLoading = true
        return exportResult(queryParams)
      }).then(response => {
        this.$download.name(response.msg)
        this.exportLoading = false
      }).catch(() => {
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams
      this.$modal.confirm('是否确认导出所有考生考试项目汇总成绩数据项？').then(() => {
        this.exportLoading = true
        return exportResult2(queryParams)
      }).then(response => {
        this.$download.name(response.msg)
        this.exportLoading = false
      }).catch(() => {
      })
    },
    //打印
    handlePrint() {
      this.loading = true
      print(this.queryParams).then(response => {
        console.log(response.data)
        this.loading = false
        let tableDiv = '<table>' +
          '<tr>' +
          '<th>序号</th>' +
          '<th>学校名称</th>' +
          '<th>学校代码</th>' +
          '<th>班级代码</th>' +
          '<th>考生姓名</th>' +
          '<th>准考号</th>' +
          '<th>性别</th>' +
          '<th>必测项</th>' +
          '<th>选测项1</th>' +
          '<th>选测项2</th>' +
          '<th>平时成绩</th>' +
          '<th>打印状态</th>' +
          '<th>考试时间</th>' +
          '</tr>'
        for (let i = 0; i < response.data.length; i++) {
          let genderLet = ''
          if (1 == response.data[i].gender) {
            genderLet = '男'
          } else {
            genderLet = '女'
          }
          let tr1 = '<tr>' +
            '<td>' + (i + 1) + '</td>' +
            '<td>' + response.data[i].school + '</td>' +
            '<td>' + response.data[i].schoolCode + '</td>' +
            '<td>' + response.data[i].schoolClass + '</td>' +
            '<td>' + response.data[i].ksName + '</td>' +
            '<td>' + response.data[i].zkz + '</td>' +
            '<td>' + genderLet + '</td>' +
            '<td>' + this.returnExamInfo(response.data[i].bctyxmName, response.data[i].bctyxmStatus, response.data[i].bctyxmValue) + '</td>' +
            '<td>' + this.returnExamInfo(response.data[i].xctyxm1Name, response.data[i].xctyxm1Status, response.data[i].xctyxm1Value) + '</td>' +
            '<td>' + this.returnExamInfo(response.data[i].xctyxm2Name, response.data[i].xctyxm2Status, response.data[i].xctyxm2Value) + '</td>' +
            '<td>' + response.data[i].usualResults + '</td>' +
            '<td>' + response.data[i].dyzt + '</td>' +
            '<td>' + response.data[i].gmtModified + '</td>' +
            '</tr>'
          tableDiv += tr1
        }
        tableDiv += '</table>'
        printExcel1(tableDiv)
      })
    },
    //处理项目变更
    changeOption3(value) {
      this.$forceUpdate()
      let self = this
      let data = {
        ksId: self.form3.id,
        projectId: value
      }
      getResult(data).then(response => {
        if (200 == response.code) {
          this.form3.cj = response.data.result + response.data.resultUnit
        }
      }).catch(response => {
        console.log(response)
      })
    },
    handleUpdateType1(row) {
      this.$prompt('请输入密码', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(({ value }) => {
        this.dict.type.extra_password.forEach(item => {
          if (item.label === 'pw_sxck') {
            if (value === item.value) {
              this.reset1()
              candidatesDetail(row.id).then(response => {
                this.dialogImageUrl = response.data.zpStr
                this.form1 = response.data
                this.form1.ksName = response.data.name
                this.form1.zkz = response.data.zkh
                this.xmlxList = [
                  { label: row.bctyxmName, value: row.bctyxmId },
                  { label: row.xctyxm1Name, value: row.xctyxm1Id },
                  { label: row.xctyxm2Name, value: row.xctyxm2Id }
                ]
                this.rules.xmlx = {}
                this.rules.result = {}
                this.form1.type = '三项重考'
                this.updateTitle1 = '三项重考'
                this.updateOpen1 = true
              })

            } else {
              this.$modal.msgError('密码错误')
            }
          }
        })
      }).catch(() => {
      })
    },
    handleUpdateType11(row) {
      this.passwordLabel = 'pw_sxck'
      this.passwordOpen = true
      this.passwordTitle = '确认密码'
      this.passwordForm.password = ''
      this.passwordRow = row
    },
    handlePassword(row) {
      console.log(this.passwordLabel)
      console.log(this.passwordForm.password)
      try {
        this.dict.type.extra_password.forEach(item => {
          if (this.passwordLabel === 'pw_sxck') {
            if (this.passwordForm.password === item.value) {
              this.passwordOpen = false
              this.reset1()
              candidatesDetail(row.id).then(response => {
                this.dialogImageUrl = response.data.zpStr
                this.form1 = response.data
                this.form1.ksName = response.data.name
                this.form1.zkz = response.data.zkh
                this.xmlxList = [
                  { label: row.bctyxmName, value: row.bctyxmId },
                  { label: row.xctyxm1Name, value: row.xctyxm1Id },
                  { label: row.xctyxm2Name, value: row.xctyxm2Id }
                ]
                this.rules.xmlx = {}
                this.rules.result = {}
                this.form1.type = '三项重考'
                this.updateTitle1 = '三项重考'
                this.updateOpen1 = true
              })
            } else {
              this.$modal.msgError('密码错误')
            }
            throw ('结束')
          } else if (this.passwordLabel === 'pw_ckdj') {
            if (this.passwordForm.password === item.value) {
              this.passwordOpen = false
              this.reset2()
              this.form2.type = '4'
              this.form2.pointId = row.pointId
              this.form2.id = row.id
              candidatesDetail(row.id).then(response => {
                this.dialogImageUrl = response.data.zpStr
                this.form2.ksName = response.data.name
                this.form2.zkz = response.data.zkh
                this.xmlxList = [
                  { label: row.bctyxmName, value: row.bctyxmId },
                  { label: row.xctyxm1Name, value: row.xctyxm1Id },
                  { label: row.xctyxm2Name, value: row.xctyxm2Id }
                ]
                this.rules.result = {}
                this.updateTitle2 = '重考登记'
                this.updateOpen2 = true
                this.rules.xmlx = { required: true, message: '登记项目不能为空', trigger: 'blur' }
              })
            } else {
              this.$modal.msgError('密码错误')
            }
            throw ('结束')
          } else if (this.passwordLabel === 'qw_xgcj') {
            if (this.passwordForm.password === item.value) {
              this.passwordOpen = false
              this.reset3()
              this.form3 = row
              this.form3.type = '6'
              candidatesDetail(row.id).then(response => {
                this.dialogImageUrl = response.data.zpStr
                this.xmlxList = [
                  { label: row.bctyxmName, value: row.bctyxmId },
                  { label: row.xctyxm1Name, value: row.xctyxm1Id },
                  { label: row.xctyxm2Name, value: row.xctyxm2Id }
                ]
                this.updateTitle3 = '成绩修正'
                this.updateOpen3 = true
                this.rules.xmlx = { required: true, message: '登记项目不能为空', trigger: 'blur' }
                this.rules.result = { required: true, message: '成绩不能为空', trigger: 'blur' }
              })
            } else {
              this.$modal.msgError('密码错误')
            }
            throw ('结束')
          }
        })
      } catch (e) {

      }
    },
    handleUpdateType2(row) {
      this.$prompt('请输入密码', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(({ value }) => {
        this.dict.type.extra_password.forEach(item => {
          if (item.label === 'pw_ckdj') {
            if (value === item.value) {
              this.reset2()
              this.form2.type = '4'
              this.form2.pointId = row.pointId
              this.form2.id = row.id
              candidatesDetail(row.id).then(response => {
                this.dialogImageUrl = response.data.zpStr
                this.form2.ksName = response.data.name
                this.form2.zkz = response.data.zkh
                this.xmlxList = [
                  { label: row.bctyxmName, value: row.bctyxmId },
                  { label: row.xctyxm1Name, value: row.xctyxm1Id },
                  { label: row.xctyxm2Name, value: row.xctyxm2Id }
                ]
                this.rules.result = {}
                this.updateTitle2 = '重考登记'
                this.updateOpen2 = true
                this.rules.xmlx = { required: true, message: '登记项目不能为空', trigger: 'blur' }
              })
            } else {
              this.$modal.msgError('密码错误')
            }
          }
        })
      }).catch(() => {
      })
    },
    handleUpdateType22(row) {
      this.passwordLabel = 'pw_ckdj'
      this.passwordOpen = true
      this.passwordTitle = '确认密码'
      this.passwordForm.password = ''
      this.passwordRow = row
    },
    handleUpdateType3(row) {
      this.$prompt('请输入密码', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(({ value }) => {
        this.dict.type.extra_password.forEach(item => {
          if (item.label === 'qw_xgcj') {
            if (value === item.value) {
              this.reset3()
              this.form3 = row
              this.form3.type = '6'
              candidatesDetail(row.id).then(response => {
                this.dialogImageUrl = response.data.zpStr
                this.xmlxList = [
                  { label: row.bctyxmName, value: row.bctyxmId },
                  { label: row.xctyxm1Name, value: row.xctyxm1Id },
                  { label: row.xctyxm2Name, value: row.xctyxm2Id }
                ]
                this.updateTitle3 = '成绩修正'
                this.updateOpen3 = true
                this.rules.xmlx = { required: true, message: '登记项目不能为空', trigger: 'blur' }
                this.rules.result = { required: true, message: '成绩不能为空', trigger: 'blur' }
              })
            } else {
              this.$modal.msgError('密码错误')
            }
          }
        })
      }).catch(() => {
      })
    },
    handleUpdateType33(row) {
      this.passwordLabel = 'qw_xgcj'
      this.passwordOpen = true
      this.passwordTitle = '确认密码'
      this.passwordForm.password = ''
      this.passwordRow = row
    },
    // 表单重置
    reset1() {
      this.form1 = {}
      this.resetForm('form1')
    },
    // 表单重置
    reset2() {
      this.form2 = {}
      this.resetForm('form2')
    },
    // 表单重置
    reset3() {
      this.form3 = {}
      this.resetForm('form3')
    },
    // 取消按钮
    cancel1() {
      this.updateOpen1 = false
      this.reset1()
    },
    // 取消按钮
    cancel2() {
      this.updateOpen2 = false
      this.reset2()
    },
    // 取消按钮
    cancel3() {
      this.updateOpen3 = false
      this.reset3()
    },
    //计算修正后成绩
    computeFraction() {
      if (this.form3.result != null && null != this.form3.xmlx) {
        const data = {
          ksId: this.form3.id,
          examId: this.form3.xmlx,
          result: this.form3.result
        }
        computeFraction(data).then(response => {
          if (response.data.status === 'success') {
            this.form3.score = response.data.data.cj
          } else {
            this.$modal.msgError(response.data.message)
          }
        })
      }
    },
    /** 提交按钮1 */
    submitForm1() {
      this.$refs['form1'].validate(valid => {
          if (valid) {
            const datas = []
            for (let i = 0; i < 3; i++) {
              let data = {
                ksId: this.form1.id,
                reason: this.form1.reason,
                pointId: this.form1.pointId,
                type: '4',
                examId: this.xmlxList[i].value
              }
              datas.push(data)
            }
            examSpecialRecords3(datas).then(response => {
              if (response.status === 'success') {
                this.$modal.msgSuccess('登记成功')
                this.updateOpen1 = false
                this.getList()
              } else {
                this.$modal.msgSuccess(response.message)
              }
            })

          }
        }
      )
    },
    /** 提交按钮2 */
    submitForm2() {
      this.$refs['form2'].validate(valid => {
          if (valid) {
            const data = {
              ksId: this.form2.id,
              reason: this.form2.reason,
              pointId: this.form2.pointId
            }
            data.examId = this.form2.xmlx
            data.type = this.form2.type
            examSpecialRecords(data).then(response => {
              if (response.status === 'success') {
                this.$modal.msgSuccess('登记成功')
                this.updateOpen2 = false
                this.getList()
              } else {
                this.$modal.msgSuccess(response.message)
              }
            })
          }
        }
      )
    },
    /** 提交按钮3 */
    submitForm3() {
      this.$refs['form3'].validate(valid => {
          if (valid) {
            const data = {
              ksId: this.form3.id,
              reason: this.form3.reason,
              pointId: this.form3.pointId
            }
            data.examId = this.form3.xmlx
            //成绩修正
            data.result = this.form3.result
            const datas = {
              data: data
            }
            updateResult(datas).then(response => {
              if (response.status === 'success') {
                this.$modal.msgSuccess('修改成功')
                this.updateOpen3 = false
                this.getList()
              } else {
                this.$modal.msgSuccess(response.message)
              }
            })
          }
        }
      )
    },
    /** 输入密码 */
    submitPasswordForm() {
      this.$refs['passwordForm'].validate(valid => {
        if (valid) {
          this.handlePassword(this.passwordRow)
        }
      })
    },
    // 取消按钮
    passwordCancel() {
      this.passwordOpen = false
      this.passwordForm.password = ''
      this.passwordLabel = ''
      this.passwordRow = null
    },
    returnExamInfo(name, status, value) {
      if (status === '缓考' || status === '未考' || status === '重考') {
        return name + ' - ' + status
      }
      if (status === '设备' || status === '人工' || status === '修改成绩') {
        return name + ' - 已考 - ' + value + '分'
      }
      if (name == null) {
        return '-'
      }
      return name + ' - ' + status + ' - ' + value + '分'
    }
  }
}
</script>
